<div class="row">
	<div class="col-md-12">
		<h1>Sản phẩm <small>Danh sách các sản phẩm</small></h1>
		<ol class="breadcrumb">
            <li><a href="<?php echo mns_page_url(); ?>"><i class="fa fa-dashboard"></i> Dashboard</a></li>
            <li><a href="<?php echo mns_product_url(); ?>"><i class="fa fa-table"></i> Sản phẩm</a></li>
        </ol>
    </div>
</div>

<div class="row">
    <div class="col-md-6 col-xs-12">
        <form method="get" action="<?php echo mns_page_url(PRODUCT_SLUG.'/tim-kiem'); ?>" enctype="multipart/form-data">
            <div class="input-group">
                <input type="text" class="form-control" name="s" value="<?php echo isset($searchkey)?$searchkey:''; ?>" placeholder="Tìm kiếm sản phẩm" />
                <span class="input-group-btn">
                    <button class="btn btn-success" type="submit"><i class='glyphicon glyphicon-search'></i> Tìm kiếm!</button>
                </span>
            </div><!-- /input-group -->
        </form>
    </div>
    <div class="col-md-6 col-xs-12">
        <p class="pull-right">
            <a class="btn btn-success" href="<?php echo mns_page_url(PRODUCT_SLUG.'/them'); ?>"><i class="glyphicon glyphicon-plus-sign"></i> Thêm sản phẩm</a>
            <?php if($this->input->get('f')!=false || $this->input->get('f', true)=='trash') { ?>
            <a class="btn btn-default" href="<?php echo mns_page_url(PRODUCT_SLUG); ?>"><i class="fa fa-trash-o"></i> Hiển thị</a>
            <?php } else { ?>
            <a class="btn btn-default" href="<?php echo mns_page_url(PRODUCT_SLUG, array('f'=>'trash')); ?>"><i class="fa fa-trash-o"></i> Không hiển thị</a>
            <?php } ?>
        </p>
    </div>
    <div class="clearfix"></div>

    <div class="col-md-12 col-xs-12">
        <?php echo $pagingBar; ?>
    </div>

    <div class="col-md-12">
        <div class="table-responsive">
            <table class="table table-bordered table-hover tablesorter item-list" data-href="<?php echo mns_page_url(PRODUCT_SLUG . '/cap-nhat'); ?>">
                <thead>
                    <tr>
                        <th class="header"># <i class="fa fa-sort"></i></th>
                        <th class="header">&nbsp;</th>
                        <th class="header">Sản phẩm <i class="fa fa-sort"></i></th>
                        <th class="header">Danh mục <i class="fa fa-sort"></i></th>
                        <th class="header">Giá <i class="fa fa-sort"></i></th>
                        <th class="header">&nbsp;</th>
                    </tr>
                    <tr class="tr-temp hidden warning">
                        <td colspan="7">
                            <form role="form" method="post" data-callback="1" action="<?php echo mns_page_url(PRODUCT_SLUG.'/cap-nhat'); ?>">
                                <div class="row">
                                    <div class="col-md-7">
                                        <div class="form-group col-md-12 col-xs-12">
                                            <label for="input-product-title">Tên sản phẩm</label>
                                            <input type="text" class="form-control auto-slug" follow-ctr='.ctr-product-slug' id="input-product-title" name="product[title]" value="" />
                                        </div>
                                        <div class="form-group col-md-12 col-xs-12">
                                            <label for="input-product-slug">Đường dẫn</label>
                                            <input type="text" class="form-control ctr-product-slug" id="input-product-slug" name="product[slug]" value="" />
                                        </div>
                                        <div class="form-group col-md-6 col-xs-12">
                                            <label for="input-product-cate">Danh mục</label>
                                            <select class="form-control" id="input-product-cate" name="product[product_cate]">
                                                <?php foreach($aShopCategory as $sc) { ?>
                                                <option value="<?php echo $sc->getId(); ?>"><?php echo $sc->getTitle(); ?></option>
                                                <?php } ?>
                                            </select>
                                        </div>
                                        <div class="form-group col-md-6 col-xs-12">
                                            <label for="input-product-code">Mã sản phẩm</label>
                                            <input type="text" class="form-control" id="input-product-code" name="product_detail[0][code]" value="" />
                                        </div>
                                        <div class="form-group col-md-6 col-xs-12">
                                            <label for="input-product-price-old">Giá cũ</label>
                                            <input type="text" class="form-control" id="input-product-price-old" name="product_detail[0][price_old]" value="" />
                                        </div>
                                        <div class="form-group col-md-6 col-xs-12">
                                            <label for="input-product-price-new">Giá mới</label>
                                            <input type="text" class="form-control" id="input-product-price-new" name="product_detail[0][price_new]" value="" />
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="checkbox">
                                            <label for="input-product-sale-flg">
                                                <input type="checkbox" id="input-product-sale-flg" name="product[sale_flg]" value="1" />Giảm giá
                                            </label>
                                        </div>
                                        <div class="checkbox">
                                            <label for="input-product-active-flg">
                                                <input type="checkbox" id="input-product-active-flg" name="product[active_flg]" value="1" />Hiển thị
                                            </label>
                                        </div>
                                        <div class="checkbox">
                                            <label for="input-product-delete-flg">
                                                <input type="checkbox" id="input-product-delete-flg" name="product[delete_flg]" value="1"/> Xoá
                                            </label>
                                        </div>
                                        <input type="hidden" name="product[id]" id="input-product-id" />
                                        <input type="hidden" name="product_detail[0][id]" id="input-product-detail-id" />
                                        <input type="hidden" name="product[update_case]" value="<?php echo UPDATE_LIST_ITEM; ?>" />
                                        <button type="button" class="btn btn-success btn-submit-update"><i class='glyphicon glyphicon-ok-sign'></i> Cập nhật</button>
                                        <button type="button" class="btn btn-danger btn-cancel-update"><i class='glyphicon glyphicon-remove-sign'></i> Huỷ</button>
                                    </div>
                                    <div class="clearfix"></div>
                                </div>
                            </form>
                        </td>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach($aProduct as $index=>$product) { ?>
                    <tr class="can-edit"
                    data-id="<?php echo $this->encrypt->encode($product->product_id); ?>"
                    data-detail-id="<?php echo $this->encrypt->encode($product->product_detail_id); ?>">
                    <th class="header bg-info"><?php echo $index+1; ?></th>
                    <td class="col-xs-12 col-md-1">
                        <div class="media">
                            <?php if($product->getImage()!='') { ?>
                            <a class="thumbnail fancybox" href="<?php echo product_upload($product->getImage(), $product->shop_image_folder, false); ?>">
                                <img class="media-object minW-96" src="<?php echo product_upload($product->getImage(), $product->shop_image_folder); ?>" />
                            </a>
                            <?php } else { ?>
                            <a class="thumbnail fancybox" href="#">
                                <img class="media-object minW-96" data-src="holder.js/100%x96" />
                            </a>
                            <?php } ?>
                        </div>
                    </td>
                    <td class="input-product">
                        <h4><a class="product-title text-capitalize" href="<?php echo mns_product_single_url($product->product_slug); ?>"><?php echo $product->product_title; ?></a></h4>
                        <p class="product-code"><?php echo $product->getCode(); ?></p>
                        <p><a class="product-slug" href="<?php echo product_url($product->product_slug); ?>"><?php echo $product->product_slug; ?></a></p>
                        <p><em><?php echo fdate_format($product->product_created_at); ?></em></p>
                    </td>
                    <td class="input-product-cate">
                        <h5>
                            <a class="cate" href="<?php echo category_url($product->category_slug); ?>">
                                <?php echo $product->category_title; ?>
                            </a>
                        </h5>
                        <p>
                            <a class="shop-cate" data-id="<?php echo $product->shop_cate_id; ?>" href="<?php echo mns_category_single_url($product->shop_cate_slug); ?>">
                                <?php echo $product->shop_cate_title; ?>
                            </a>
                        </p>
                    </td>
                    <td class="input-product-price" data-price-old="<?php echo $product->getPriceOld(); ?>" data-price-new="<?php echo $product->getPriceNew(); ?>">
                        <span class="price-new normal-price-style" ><?php echo currency_format($product->getPriceNew()); ?></span>
                        <br/>
                        <span class="price-old normal-old-price-style"><?php echo currency_format($product->getPriceOld()); ?></span>
                    </td>
                    <td class="input-product-flg">
                        <div class="checkbox inline-table clearMgr">
                            <input id="chk-sale-<?php echo $index+1; ?>" class="input-product-sale-flg lb-toggle" data-name="sale_flg" type="checkbox" value="1"
                            <?php echo $product->product_sale_flg!=NULL && $product->product_sale_flg==ON ?"checked='checked'":''; ?> />Giảm giá
                            <label class="mgr10" for="chk-sale-<?php echo $index+1; ?>"></label>
                        </div>
                        <div class="checkbox inline-table clearMgr">
                            <input id="chk-active-<?php echo $index+1; ?>" class="input-product-active-flg lb-toggle" data-name="active_flg" type="checkbox" value="1"
                            <?php echo $product->product_active_flg!=NULL && $product->product_active_flg==ON ?"checked='checked'":''; ?> />Hiển thị
                            <label class="mgr10" for="chk-active-<?php echo $index+1; ?>"></label>
                        </div>
                        <div class="checkbox inline-table clearMgr">
                            <input id="chk-delete-<?php echo $index+1; ?>" class="input-product-delete-flg lb-toggle red" data-name="delete_flg" type="checkbox" value="1"
                            <?php echo $product->product_deleted_at!=NULL ?"checked='checked'":''; ?> />Xoá
                            <label for="chk-delete-<?php echo $index+1; ?>"></label>
                        </div>
                    </td>
                </tr>
                <?php } ?>
            </tbody>
        </table>
    </div>
</div>
<div class="clearfix"></div>
</div>